<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Home\Controller;
use Think\Controller;

class FilmController extends BaseController {
	/*
	 * 电影PC首页
	 */
    public function index(){
		
    	$this->assign('filmarticle',$this->getfilmall());
		$this->display();
    }
    
    /*
     * 电影PC列表页
     */
    public function filmlist(){

    	$m = M('ehrcompany_singer_resource_video',null,'ODDH5_DB_CONFIG1');
    	$where['type'] = 6;
    	$count = $m->where($where)->count();
    	//每页显示条数
    	$num = 15;
    	$page = new \Think\Page($count,$num);
    	$obj = pagestyle($page);
    	$show = $obj->show();
    	$result = $m->order(array('id'=>'DESC'))->where($where)->limit($obj->firstRow.','.$obj->listRows)->select();
    	/*转换图片地址*/
    	foreach ($result as &$res){
    		if(strstr($res['video_img'],'http://h5.hrtv.cn')==true){
    			$res['video_img'] = $res['video_img'];
    		}else{
    			$res['video_img'] = "http://img.hrtv.cn/".$res['video_img'];
    		}
    	}
    	$this->assign('filmarticle',$result);
    	$this->assign('page',$show);
		$this->display();
    }
    
    /*
     * 获取所有type=6的信息
     */
    protected function getfilmall(){
    
    	$m = M('ehrcompany_singer_resource_video',null,'ODDH5_DB_CONFIG1');
    	$where['type'] = 6;
    	$result = $m->where($where)->order(array('add_time'=>'DESC'))->select();
    	/*转换图片地址*/
    	foreach ($result as &$res){
    		if(strstr($res['video_img'],'http://h5.hrtv.cn')==true){
    			$res['video_img'] = $res['video_img'];
    		}else{
    			$res['video_img'] = "http://img.hrtv.cn/".$res['video_img'];
    		}
    	}
    	return $result;
    }
    
    /*
     * 文章页
     * $id  文章ID
     */
    public function detail(){
    	$id=I('get.id');
    	if(!empty($id)){
    		$m = M('ehrcompany_singer_resource_video',null,'ODDH5_DB_CONFIG1');
    		$result = $m->find($id);
    		$vurl = str_replace('640', '980', $result['video_url']);
    		$vurl = str_replace('360', '490', $vurl);
    		$result['video_url'] = $vurl;
    		$this->assign('filmarticle',$result);
    		$this->assign('filmlist',$this->getfilmall());
    		$this->display();
    	}else{
    		$this->error('非法参数！','',1);
    	}
    }
    
    /*
     * 获取指定电影分类
     */
    public function getFilmInfoOnly($fild){
    	$id = I('get.filmcolumnid');
    	if(!empty($id)){
    		$m = M('ehrcompany_singger',null,'ODDH5_DB_CONFIG1');
    		$result = $m->where($where)->find($id);
    		echo $result[$fild];
    	}else{
    		return null;
    	}
    
    }


}